#include "C_CheckBox.h"

using namespace gui;

C_CheckBox::C_CheckBox()
: m_checked(false)
{
	m_textureChecked.loadFromFile("data/textures/gui/checkbox/checkBox_checked.png");
	m_textureUnchecked.loadFromFile("data/textures/gui/checkbox/checkBox_unchecked.png");
	this->setSize(this->m_textureChecked.pictureWidth(), m_textureChecked.pictureHeight());

	this->setContainerType(CONTAINER_HORIZONTAL);
	this->addWidget(&m_textureChecked);
	this->addWidget(&m_textureUnchecked);
	this->complexUpdate();
}


C_CheckBox::~C_CheckBox()
{
}

void C_CheckBox::renderWidget()
{
	if (m_checked)
	{
		m_textureChecked.show();
		m_textureUnchecked.hide();
	}
	else
	{
		m_textureChecked.hide();
		m_textureUnchecked.show();
	}
}

void C_CheckBox::onClickButton(sf::Mouse::Button b_type)
{
	if (b_type == sf::Mouse::Button::Left)
	{
		m_checked = !m_checked;
	}
}
